/**
 * 
 */
package com.oolong.account.model.factory;

import com.oolong.account.dal.IntypeDAO;
import com.oolong.account.dal.OuttypeDAO;
import com.oolong.account.dal.data.Intype;
import com.oolong.account.dal.data.Outtype;
import com.oolong.account.model.InTypeModel;
import com.oolong.account.model.OutTypeGroup;
import com.oolong.account.model.OutTypeModel;

/**
 * @author oolong
 * 
 */
public class TypeFactory {
	IntypeDAO intypeDAO;
	OuttypeDAO outtypeDAO;

	public InTypeModel getInTypeModel(int id) {

		Intype intype = intypeDAO.selectByPrimaryKey(new Integer(id));
		InTypeModel inTypeModel = new InTypeModel(intype.getId(),
				intype.getName());

		return inTypeModel;
	}

	public OutTypeModel getIOutTypeModel(int id) {

		Outtype Fatherouttype = outtypeDAO.selectByPrimaryKey(id);
		OutTypeModel outTypeModel = new OutTypeModel();
		outTypeModel.setId(Fatherouttype.getId());
		outTypeModel.setName(Fatherouttype.getName());
		OutTypeGroup outTypeGroup = new OutTypeGroup();
		Outtype sonouttype = outtypeDAO.selectByPrimaryKey(Fatherouttype
				.getGroup_id());
		outTypeGroup.setId(sonouttype.getId());
		outTypeGroup.setName(sonouttype.getName());
		outTypeModel.setOutTypeGroup(outTypeGroup);

		return outTypeModel;
	}

	/**
	 * @param intypeDAO
	 *            the intypeDAO to set
	 */
	public void setIntypeDAO(IntypeDAO intypeDAO) {
		this.intypeDAO = intypeDAO;
	}

	/**
	 * @param outtypeDAO
	 *            the outtypeDAO to set
	 */
	public void setOuttypeDAO(OuttypeDAO outtypeDAO) {
		this.outtypeDAO = outtypeDAO;
	}

}
